//--------------------------------------------------------------------------
// $Id: AssociateRequest.java 5 2006-08-20 20:48:08Z zendragon $
//--------------------------------------------------------------------------
// Copyright 2006 Social Brain Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//--------------------------------------------------------------------------

package org.socialbrain.openid;

import org.apache.commons.lang.StringUtils;

import java.math.BigInteger;

/**
 * @author <a href="http://erning.net/">Zhang Erning</a>
 * @version $Id: AssociateRequest.java 5 2006-08-20 20:48:08Z zendragon $
 */
public class AssociateRequest extends KeyValuePairs
{
    public AssociateRequest()
    {
        put(Constants.PARAM_MODE, Constants.MODE_ASSOCIATE);
    }

    public AssociateRequest(KeyValuePairs pairs)
    {
        super(pairs);
    }

    // commons

    public String getMode()
    {
        return get(Constants.PARAM_MODE);
    }

    public void setAssocType(String value)
    {
        put(Constants.PARAM_ASSOC_TYPE, value);
    }

    public String getAssocType()
    {
        return get(Constants.PARAM_ASSOC_TYPE);
    }

    public void setSessionType(String value)
    {
        put(Constants.PARAM_SESSION_TYPE, value);
    }

    public String getSessionType()
    {
        return get(Constants.PARAM_SESSION_TYPE);
    }

    // Unencrypted
    
    public boolean isUnencrypted()
    {
        return StringUtils.isEmpty(getSessionType())
                || Constants.SESSION_NO_ENCRYPTION.equals(getSessionType());
    }

    // Diffie-Hellman

    public void setDhModulus(BigInteger value)
    {
        putAsBigInteger(Constants.PARAM_DH_MODULUS, value);
    }

    public BigInteger getDhModules()
    {
        return getAsBigInteger(Constants.PARAM_DH_MODULUS);
    }

    public void setDhGen(BigInteger value)
    {
        putAsBigInteger(Constants.PARAM_DH_GEN, value);
    }

    public BigInteger getDhGen()
    {
        return getAsBigInteger(Constants.PARAM_DH_GEN);
    }

    public void setDhConsumerPublic(BigInteger value)
    {
        putAsBigInteger(Constants.PARAM_DH_CONSUMER_PUBLIC, value);
    }

    public BigInteger getConsumerPublic()
    {
        return getAsBigInteger(Constants.PARAM_DH_CONSUMER_PUBLIC);
    }
}
